package InterFaceContact;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import com.mxgraph.view.mxGraph;

public class Position {
	
	static HashMap<String, Double[]> pos = new HashMap<String, Double[]>();
	static HashMap<String, List<String> > lig = new HashMap<String, List<String>>();
	
	
	public static void preenchePosicoes(mxGraph graph, HashMap<String, Object> m) {
		preenchePos(graph, m);
	}

	public static void insereLinha(String no1, String no2){
		if(lig.containsKey(no1)){
			lig.get(no1).add(no2);
		}else{
			lig.put(no1, new ArrayList<String>());
			lig.get(no1).add(no2);
		}
		
		if(lig.containsKey(no2)){
			lig.get(no2).add(no1);
		}else{
			lig.put(no2, new ArrayList<String>());
			lig.get(no2).add(no1);
		}
	}
	
	private static void preenchePos(mxGraph graph, HashMap<String, Object> m) {
		Iterator<String> it = m.keySet().iterator();
		String key = new String();
		
		while(it.hasNext()){
			key = it.next();
			pos.put(key, new Double[2]);
			pos.get(key)[0] = graph.getCellBounds(m.get(key)).getCenterX();
			pos.get(key)[1] = graph.getCellBounds(m.get(key)).getCenterY();
		}
		
	}

	public static HashMap<String, Double[]> getPos() {
		return pos;
	}

	public static void setPos(HashMap<String, Double[]> pos) {
		Position.pos = pos;
	}

	public static HashMap<String, List<String>> getLig() {
		return lig;
	}
	public static void setLig(HashMap<String, List<String>> lig) {
		Position.lig = lig;
	}

}
